# -*- coding: utf-8 -*-
"""
@Time ： 2025/8/27 16:05
@Auth ： 李天天
"""
import time

from Common.browser_config import quick_start
from PageObjects.Mine_Page import MinePage
from PageObjects.Main_Page import MainPage

pw, browser, context, page = quick_start(auto_login=True)

DEBUG = False
do_mainpage = MainPage(page)
do_minepage = MinePage(page)


def step_01():
    print("开始执行操作--1")
    i = 1 if DEBUG else 3
    for i in range(i):
        for channel in ["电视剧", "电影", "综艺", "儿童", "动漫", "纪录片", "推荐"]:
            do_mainpage.click_channel(channel)
            time.sleep(2)
            for i_down in range(3):
                do_mainpage.scroll_iqiyi_page()
                time.sleep(1)


def step_02():
    print("开始执行操作--2")
    i = 1 if DEBUG else 10
    do_mainpage.click_personal_center()
    time.sleep(3)
    for i in range(i):
        do_minepage.click_history()
        time.sleep(3)
        do_minepage.click_back()
        time.sleep(2)
        do_minepage.click_collection()
        time.sleep(3)
        do_minepage.click_back()
        time.sleep(2)
        do_minepage.click_settings()
        time.sleep(3)
        do_minepage.click_back()
        time.sleep(2)
    time.sleep(2)
    do_minepage.click_back()


def step_03():
    print("开始执行操作--3")
    i = 1 if DEBUG else 10
    for i in range(i):
        for channel in ["电视剧", "电影", "综艺"]:
            do_mainpage.click_channel(channel)
            time.sleep(2)
            do_mainpage.scroll_iqiyi_page(-500)
            time.sleep(2)
            for i_down in range(30):
                do_mainpage.scroll_iqiyi_page()
                # time.sleep(1)
            time.sleep(3)
            do_mainpage.click_back_top()
            time.sleep(3)


def step_04():
    print("开始执行操作--4")
    i = 1 if DEBUG else 3
    for i in range(i):
        for channel in ["电视剧", "电影", "综艺"]:
            do_mainpage.click_channel(channel)
            time.sleep(2)
            do_mainpage.click_filter()
            time.sleep(2)
            for i_down in range(30):
                do_mainpage.scroll_iqiyi_page()
            time.sleep(3)
            for i_up in range(30):
                do_mainpage.scroll_iqiyi_page(distance=-500)
            time.sleep(2)
            do_mainpage.click_back()


def step_05():
    print("开始执行操作--5")
    i = 1 if DEBUG else 10
    for i in range(i):
        do_mainpage.click_search()
        time.sleep(2)
        # do_mainpage.click_back()
        # time.sleep(2)
        do_mainpage.click_back()
        time.sleep(2)
        do_mainpage.click_history()
        time.sleep(2)
        do_mainpage.click_back()


def step_06():
    print("操作结束，等待30秒")
    time.sleep(30)


def run_no_play_scene():
    do_mainpage.goto("https://www.iqiyi.com/iv#/?ver=tesla")
    time.sleep(3)
    step_01()
    step_02()
    step_03()
    step_04()
    step_05()
    step_06()

if __name__ == '__main__':
    run_no_play_scene()
